<?php
function jiduzsf($nowdate,$nowjidu,$admincity){
	global $db;
	if($db->pe_select("jiduzsf",array('jiduzsf_date'=>$nowdate."-".$nowjidu."-00",'jiduzsf_user_company'=>$admincity))){
				
	}else{
		if($nowjidu=="01"){
			$one = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-01-00",'zsf_user_company'=>$admincity));
			$two = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-02-00",'zsf_user_company'=>$admincity));
			$three = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-03-00",'zsf_user_company'=>$admincity));
			if($one&&$two&&$three){					
				$three_list = $db->pe_selectall("zsf",array('zsf_date'=>$nowdate."-03-00",'zsf_user_company'=>$admincity));						
				foreach($three_list as $k=>$v){
					$result = $v['zsf_result'];
					if($onecode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-01-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
						$result += $onecode['zsf_result'];
					}
					if($twocode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-02-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
						$result += $onecode['zsf_result'];
					}
					$set['jiduzsf_date'] = $nowdate."-01-00";
					$set['jiduzsf_user_code'] = $v['zsf_user_code'];
					$set['jiduzsf_user_name'] = $v['zsf_user_name'];
					$set['jiduzsf_user_company'] = $v['zsf_user_company'];
					$set['jiduzsf_user_branch'] = $v['zsf_user_branch'];
					$set['jiduzsf_user_job'] = $v['zsf_user_job'];
					$set['jiduzsf_all'] = $result;
					$db->pe_insert("jiduzsf", $set);
				}
				$job_list = $db->pe_selectall("job");
				$zscs = array();
				$mostjifen = array();
				foreach($job_list as $v){
					$zscs[$v['job_name']] = $v['job_zsf_value'];
					$zsf_jifenmost = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-01-00",'jiduzsf_user_job'=>$v['job_name'],"order by"=>'jiduzsf_all desc'),'jiduzsf_all',array(1));
					if($zsf_jifenmost[0]['jiduzsf_all']){
						$mostjifen[$v['job_name']] = $zsf_jifenmost[0]['jiduzsf_all'];
					}else{
						$mostjifen[$v['job_name']] = 0;
					}
					
				}
				//print_r($mostjifen);die;
				$jiduzsf_list = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-01-00",'jiduzsf_user_company'=>$admincity));										
				foreach($jiduzsf_list as $v){
					if($mostjifen[$v['jiduzsf_user_job']]>0){							
						$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>round($v['jiduzsf_all']/$mostjifen[$v['jiduzsf_user_job']]*$zscs[$v['jiduzsf_user_job']], 2)));
					}else{								
						$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>0));
					}
				}
			}
		}elseif($nowjidu=="02"){
			$one = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-04-00",'zsf_user_company'=>$admincity));
			$two = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-05-00",'zsf_user_company'=>$admincity));
			$three = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-06-00",'zsf_user_company'=>$admincity));
			if($one&&$two&&$three){
				$three_list = $db->pe_selectall("zsf",array('zsf_date'=>$nowdate."-06-00",'zsf_user_company'=>$admincity));						
				foreach($three_list as $k=>$v){
					$result = $v['zsf_result'];
					if($onecode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-04-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
						$result += $onecode['zsf_result'];
					}
					if($twocode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-05-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
						$result += $onecode['zsf_result'];
					}
					$set['jiduzsf_date'] = $nowdate."-02-00";
					$set['jiduzsf_user_code'] = $v['zsf_user_code'];
					$set['jiduzsf_user_name'] = $v['zsf_user_name'];
					$set['jiduzsf_user_company'] = $v['zsf_user_company'];
					$set['jiduzsf_user_branch'] = $v['zsf_user_branch'];
					$set['jiduzsf_user_job'] = $v['zsf_user_job'];
					$set['jiduzsf_all'] = $result;
					$db->pe_insert("jiduzsf", $set);
				}
					
				$job_list = $db->pe_selectall("job");
				$zscs = array();
				$mostjifen = array();
				foreach($job_list as $v){
					$zscs[$v['job_name']] = $v['job_zsf_value'];
					$zsf_jifenmost = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-02-00",'jiduzsf_user_job'=>$v['job_name'],"order by"=>'jiduzsf_all desc'),'jiduzsf_all',array(1));
					if($zsf_jifenmost[0]['jiduzsf_all']){
						$mostjifen[$v['job_name']] = $zsf_jifenmost[0]['jiduzsf_all'];
					}else{
						$mostjifen[$v['job_name']] = 0;
					}
					
				}
				//print_r($mostjifen);die;
				$jiduzsf_list = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-02-00",'jiduzsf_user_company'=>$admincity));										
				foreach($jiduzsf_list as $v){
					if($mostjifen[$v['jiduzsf_user_job']]>0){							
						$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>round($v['jiduzsf_all']/$mostjifen[$v['jiduzsf_user_job']]*$zscs[$v['jiduzsf_user_job']], 2)));
					}else{								
						$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>0));
					}
				}
			}
		}elseif($nowjidu=="03"){
			$one = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-07-00",'zsf_user_company'=>$admincity));
			$two = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-08-00",'zsf_user_company'=>$admincity));
			$three = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-09-00",'zsf_user_company'=>$admincity));
			if($one&&$two&&$three){
				$three_list = $db->pe_selectall("zsf",array('zsf_date'=>$nowdate."-09-00",'zsf_user_company'=>$admincity));						
				foreach($three_list as $k=>$v){
					$result = $v['zsf_result'];
					if($onecode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-07-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
						$result += $onecode['zsf_result'];
					}
					if($twocode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-08-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
						$result += $onecode['zsf_result'];
					}
					$set['jiduzsf_date'] = $nowdate."-03-00";
					$set['jiduzsf_user_code'] = $v['zsf_user_code'];
					$set['jiduzsf_user_name'] = $v['zsf_user_name'];
					$set['jiduzsf_user_company'] = $v['zsf_user_company'];
					$set['jiduzsf_user_branch'] = $v['zsf_user_branch'];
					$set['jiduzsf_user_job'] = $v['zsf_user_job'];
					$set['jiduzsf_all'] = $result;
					$db->pe_insert("jiduzsf", $set);
				}
					
				$job_list = $db->pe_selectall("job");
				$zscs = array();
				$mostjifen = array();
				foreach($job_list as $v){
					$zscs[$v['job_name']] = $v['job_zsf_value'];
					$zsf_jifenmost = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-03-00",'jiduzsf_user_job'=>$v['job_name'],"order by"=>'jiduzsf_all desc'),'jiduzsf_all',array(1));
					if($zsf_jifenmost[0]['jiduzsf_all']){
						$mostjifen[$v['job_name']] = $zsf_jifenmost[0]['jiduzsf_all'];
					}else{
						$mostjifen[$v['job_name']] = 0;
					}
					
				}
				//print_r($mostjifen);die;
				$jiduzsf_list = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-03-00",'jiduzsf_user_company'=>$admincity));										
				foreach($jiduzsf_list as $v){
					if($mostjifen[$v['jiduzsf_user_job']]>0){							
						$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>round($v['jiduzsf_all']/$mostjifen[$v['jiduzsf_user_job']]*$zscs[$v['jiduzsf_user_job']], 2)));
					}else{								
						$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>0));
					}
				}
			}
		}elseif($nowjidu=="04"){
			$one = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-10-00",'zsf_user_company'=>$admincity));
			$two = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-11-00",'zsf_user_company'=>$admincity));
			$three = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-12-00",'zsf_user_company'=>$admincity));
			if($one&&$two&&$three){
				$three_list = $db->pe_selectall("zsf",array('zsf_date'=>$nowdate."-12-00",'zsf_user_company'=>$admincity));						
				foreach($three_list as $k=>$v){
					$result = $v['zsf_result'];
					if($onecode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-10-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
						$result += $onecode['zsf_result'];
					}
					if($twocode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-11-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
						$result += $onecode['zsf_result'];
					}
					$set['jiduzsf_date'] = $nowdate."-04-00";
					$set['jiduzsf_user_code'] = $v['zsf_user_code'];
					$set['jiduzsf_user_name'] = $v['zsf_user_name'];
					$set['jiduzsf_user_company'] = $v['zsf_user_company'];
					$set['jiduzsf_user_branch'] = $v['zsf_user_branch'];
					$set['jiduzsf_user_job'] = $v['zsf_user_job'];
					$set['jiduzsf_all'] = $result;
					$db->pe_insert("jiduzsf", $set);
				}
					
				$job_list = $db->pe_selectall("job");
				$zscs = array();
				$mostjifen = array();
				foreach($job_list as $v){
					$zscs[$v['job_name']] = $v['job_zsf_value'];
					$zsf_jifenmost = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-04-00",'jiduzsf_user_job'=>$v['job_name'],"order by"=>'jiduzsf_all desc'),'jiduzsf_all',array(1));
					if($zsf_jifenmost[0]['jiduzsf_all']){
						$mostjifen[$v['job_name']] = $zsf_jifenmost[0]['jiduzsf_all'];
					}else{
						$mostjifen[$v['job_name']] = 0;
					}
					
				}
				//print_r($mostjifen);die;
				$jiduzsf_list = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-04-00",'jiduzsf_user_company'=>$admincity));										
				foreach($jiduzsf_list as $v){
					if($mostjifen[$v['jiduzsf_user_job']]>0){							
						$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>round($v['jiduzsf_all']/$mostjifen[$v['jiduzsf_user_job']]*$zscs[$v['jiduzsf_user_job']], 2)));
					}else{								
						$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>0));
					}
				}
			}
		}
	}
}
function rejiduzsf($nowdate,$nowjidu,$admincity){
	global $db;
	$db->pe_delete("jiduzsf",array('jiduzsf_date'=>$nowdate."-".$nowjidu."-00",'jiduzsf_user_company'=>$admincity));	
	if($nowjidu=="01"){
		$one = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-01-00",'zsf_user_company'=>$admincity));
		$two = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-02-00",'zsf_user_company'=>$admincity));
		$three = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-03-00",'zsf_user_company'=>$admincity));
		if($one&&$two&&$three){					
			$three_list = $db->pe_selectall("zsf",array('zsf_date'=>$nowdate."-03-00",'zsf_user_company'=>$admincity));						
			foreach($three_list as $k=>$v){
				$result = $v['zsf_result'];
				if($onecode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-01-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
					$result += $onecode['zsf_result'];
				}
				if($twocode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-02-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
					$result += $onecode['zsf_result'];
				}
				$set['jiduzsf_date'] = $nowdate."-01-00";
				$set['jiduzsf_user_code'] = $v['zsf_user_code'];
				$set['jiduzsf_user_name'] = $v['zsf_user_name'];
				$set['jiduzsf_user_company'] = $v['zsf_user_company'];
				$set['jiduzsf_user_branch'] = $v['zsf_user_branch'];
				$set['jiduzsf_user_job'] = $v['zsf_user_job'];
				$set['jiduzsf_all'] = $result;
				$db->pe_insert("jiduzsf", $set);
			}
			$job_list = $db->pe_selectall("job");
			$zscs = array();
			$mostjifen = array();
			foreach($job_list as $v){
				$zscs[$v['job_name']] = $v['job_zsf_value'];
				$zsf_jifenmost = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-01-00",'jiduzsf_user_job'=>$v['job_name'],"order by"=>'jiduzsf_all desc'),'jiduzsf_all',array(1));
				if($zsf_jifenmost[0]['jiduzsf_all']){
					$mostjifen[$v['job_name']] = $zsf_jifenmost[0]['jiduzsf_all'];
				}else{
					$mostjifen[$v['job_name']] = 0;
				}
				
			}
			//print_r($mostjifen);die;
			$jiduzsf_list = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-01-00",'jiduzsf_user_company'=>$admincity));										
			foreach($jiduzsf_list as $v){
				if($mostjifen[$v['jiduzsf_user_job']]>0){							
					$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>round($v['jiduzsf_all']/$mostjifen[$v['jiduzsf_user_job']]*$zscs[$v['jiduzsf_user_job']], 2)));
				}else{								
					$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>0));
				}
			}
			pe_success("计算成功！");
		}else{
			$monthnull = "";
			if(!$one){
				$monthnull = $nowdate."年01月&nbsp;";
			}
			if(!$two){
				$monthnull = $nowdate."年02月&nbsp;";
			}
			if(!$three){
				$monthnull = $nowdate."年03月&nbsp;";
			}
			pe_error("抱歉，".$monthnull."没有数据");
		}
	}elseif($nowjidu=="02"){
		$one = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-04-00",'zsf_user_company'=>$admincity));
		$two = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-05-00",'zsf_user_company'=>$admincity));
		$three = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-06-00",'zsf_user_company'=>$admincity));
		if($one&&$two&&$three){
			$three_list = $db->pe_selectall("zsf",array('zsf_date'=>$nowdate."-06-00",'zsf_user_company'=>$admincity));						
			foreach($three_list as $k=>$v){
				$result = $v['zsf_result'];
				if($onecode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-04-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
					$result += $onecode['zsf_result'];
				}
				if($twocode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-05-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
					$result += $onecode['zsf_result'];
				}
				$set['jiduzsf_date'] = $nowdate."-02-00";
				$set['jiduzsf_user_code'] = $v['zsf_user_code'];
				$set['jiduzsf_user_name'] = $v['zsf_user_name'];
				$set['jiduzsf_user_company'] = $v['zsf_user_company'];
				$set['jiduzsf_user_branch'] = $v['zsf_user_branch'];
				$set['jiduzsf_user_job'] = $v['zsf_user_job'];
				$set['jiduzsf_all'] = $result;
				$db->pe_insert("jiduzsf", $set);
			}
				
			$job_list = $db->pe_selectall("job");
			$zscs = array();
			$mostjifen = array();
			foreach($job_list as $v){
				$zscs[$v['job_name']] = $v['job_zsf_value'];
				$zsf_jifenmost = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-02-00",'jiduzsf_user_job'=>$v['job_name'],"order by"=>'jiduzsf_all desc'),'jiduzsf_all',array(1));
				if($zsf_jifenmost[0]['jiduzsf_all']){
					$mostjifen[$v['job_name']] = $zsf_jifenmost[0]['jiduzsf_all'];
				}else{
					$mostjifen[$v['job_name']] = 0;
				}
				
			}
			//print_r($mostjifen);die;
			$jiduzsf_list = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-02-00",'jiduzsf_user_company'=>$admincity));										
			foreach($jiduzsf_list as $v){
				if($mostjifen[$v['jiduzsf_user_job']]>0){							
					$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>round($v['jiduzsf_all']/$mostjifen[$v['jiduzsf_user_job']]*$zscs[$v['jiduzsf_user_job']], 2)));
				}else{								
					$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>0));
				}
			}
			pe_success("计算成功！");
		}else{
			$monthnull = "";
			if(!$one){
				$monthnull .= $nowdate."年04月&nbsp;";
			}
			if(!$two){
				$monthnull .= $nowdate."年05月&nbsp;";
			}
			if(!$three){
				$monthnull .= $nowdate."年06月&nbsp;";
			}
			pe_error("抱歉，".$monthnull."没有数据");
		}
	}elseif($nowjidu=="03"){
		$one = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-07-00",'zsf_user_company'=>$admincity));
		$two = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-08-00",'zsf_user_company'=>$admincity));
		$three = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-09-00",'zsf_user_company'=>$admincity));
		if($one&&$two&&$three){
			$three_list = $db->pe_selectall("zsf",array('zsf_date'=>$nowdate."-09-00",'zsf_user_company'=>$admincity));						
			foreach($three_list as $k=>$v){
				$result = $v['zsf_result'];
				if($onecode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-07-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
					$result += $onecode['zsf_result'];
				}
				if($twocode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-08-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
					$result += $onecode['zsf_result'];
				}
				$set['jiduzsf_date'] = $nowdate."-03-00";
				$set['jiduzsf_user_code'] = $v['zsf_user_code'];
				$set['jiduzsf_user_name'] = $v['zsf_user_name'];
				$set['jiduzsf_user_company'] = $v['zsf_user_company'];
				$set['jiduzsf_user_branch'] = $v['zsf_user_branch'];
				$set['jiduzsf_user_job'] = $v['zsf_user_job'];
				$set['jiduzsf_all'] = $result;
				$db->pe_insert("jiduzsf", $set);
			}
				
			$job_list = $db->pe_selectall("job");
			$zscs = array();
			$mostjifen = array();
			foreach($job_list as $v){
				$zscs[$v['job_name']] = $v['job_zsf_value'];
				$zsf_jifenmost = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-03-00",'jiduzsf_user_job'=>$v['job_name'],"order by"=>'jiduzsf_all desc'),'jiduzsf_all',array(1));
				if($zsf_jifenmost[0]['jiduzsf_all']){
					$mostjifen[$v['job_name']] = $zsf_jifenmost[0]['jiduzsf_all'];
				}else{
					$mostjifen[$v['job_name']] = 0;
				}
				
			}
			//print_r($mostjifen);die;
			$jiduzsf_list = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-03-00",'jiduzsf_user_company'=>$admincity));										
			foreach($jiduzsf_list as $v){
				if($mostjifen[$v['jiduzsf_user_job']]>0){							
					$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>round($v['jiduzsf_all']/$mostjifen[$v['jiduzsf_user_job']]*$zscs[$v['jiduzsf_user_job']], 2)));
				}else{								
					$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>0));
				}
			}
			pe_success("计算成功！");
		}else{
			$monthnull = "";
			if(!$one){
				$monthnull .= $nowdate."年07月&nbsp;";
			}
			if(!$two){
				$monthnull .= $nowdate."年08月&nbsp;";
			}
			if(!$three){
				$monthnull .= $nowdate."年09月&nbsp;";
			}
			pe_error("抱歉，".$monthnull."没有数据");
		}
	}elseif($nowjidu=="04"){
		$one = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-10-00",'zsf_user_company'=>$admincity));
		$two = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-11-00",'zsf_user_company'=>$admincity));
		$three = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-12-00",'zsf_user_company'=>$admincity));
		if($one&&$two&&$three){
			$three_list = $db->pe_selectall("zsf",array('zsf_date'=>$nowdate."-12-00",'zsf_user_company'=>$admincity));						
			foreach($three_list as $k=>$v){
				$result = $v['zsf_result'];
				if($onecode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-10-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
					$result += $onecode['zsf_result'];
				}
				if($twocode = $db->pe_select("zsf",array('zsf_date'=>$nowdate."-11-00",'zsf_user_code'=>$v['zsf_user_code']),'zsf_result')){
					$result += $onecode['zsf_result'];
				}
				$set['jiduzsf_date'] = $nowdate."-04-00";
				$set['jiduzsf_user_code'] = $v['zsf_user_code'];
				$set['jiduzsf_user_name'] = $v['zsf_user_name'];
				$set['jiduzsf_user_company'] = $v['zsf_user_company'];
				$set['jiduzsf_user_branch'] = $v['zsf_user_branch'];
				$set['jiduzsf_user_job'] = $v['zsf_user_job'];
				$set['jiduzsf_all'] = $result;
				$db->pe_insert("jiduzsf", $set);
			}
				
			$job_list = $db->pe_selectall("job");
			$zscs = array();
			$mostjifen = array();
			foreach($job_list as $v){
				$zscs[$v['job_name']] = $v['job_zsf_value'];
				$zsf_jifenmost = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-04-00",'jiduzsf_user_job'=>$v['job_name'],"order by"=>'jiduzsf_all desc'),'jiduzsf_all',array(1));
				if($zsf_jifenmost[0]['jiduzsf_all']){
					$mostjifen[$v['job_name']] = $zsf_jifenmost[0]['jiduzsf_all'];
				}else{
					$mostjifen[$v['job_name']] = 0;
				}
				
			}
			//print_r($mostjifen);die;
			$jiduzsf_list = $db->pe_selectall("jiduzsf",array("jiduzsf_date"=>$nowdate."-04-00",'jiduzsf_user_company'=>$admincity));										
			foreach($jiduzsf_list as $v){
				if($mostjifen[$v['jiduzsf_user_job']]>0){							
					$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>round($v['jiduzsf_all']/$mostjifen[$v['jiduzsf_user_job']]*$zscs[$v['jiduzsf_user_job']], 2)));
				}else{								
					$db->pe_update("jiduzsf",array("jiduzsf_id"=>$v['jiduzsf_id']),array('jiduzsf_result'=>0));
				}
			}
			pe_success("计算成功！");
		}else{
			$monthnull = "";
			if(!$one){
				$monthnull .= $nowdate."年10月&nbsp;";
			}
			if(!$two){
				$monthnull .= $nowdate."年11月&nbsp;";
			}
			if(!$three){
				$monthnull .= $nowdate."年12月&nbsp;";
			}
			pe_error("抱歉，".$monthnull."没有数据");
		}
	}
}
?>